//@Lim Wei Ke A0083402R
package logic;

import static org.junit.Assert.*;

import java.util.ArrayList;

import global.Task;
import org.junit.Test;

import storage.Storage;

public class UpdateCommandTest {

	@Test
	public void test() {
		Task task = new Task(null, "eat lunch", null, null, null);
		ArrayList<String> filenames = new ArrayList<String>();
		filenames.add("");
		ExecutionHandler.setDisplayFileNames(filenames);
		
		UpdateCommand update1 = new UpdateCommand(2, task, true, "");
		String feedback1 = update1.execute().get(0);
		assertEquals("Illegal index 2\n", feedback1);
		
		UpdateCommand update2 = new UpdateCommand(0, task, true, "");
		String feedback2 = update2.execute().get(0);
		assertEquals("Updating Task eat lunch unsuccessful.\n", feedback2);
		
		Storage.init();
		ArrayList<String> storageList = Storage.getFileNameList();
		filenames.add(storageList.get(0));
		ExecutionHandler.setDisplayFileNames(filenames);
		
		UpdateCommand update3 = new UpdateCommand(2, task, true, "");
		ArrayList<String> fbList = update3.execute();
		int size = fbList.size();
		String feedback3 = fbList.get(size - 1);
		assertEquals("Task updated successfully.\n", feedback3);
		
	}

}
//@Lim Wei Ke A0083402R